<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<input type="text" id="i1">
  <div id="d1">这是一个div</div>
  <input type="button" value="获取" onclick="fn1()">
  <input type="button" value="修改" onclick="fn2()">
  <input type="button" value="按钮" onclick="fn3()">
  <script type="text/javascript">
  function fn3(){
	  //取出文本框的内容 给到div显示
	  d1.innerText=i1.value;
  }
  function fn1(){
	  var d=document.getElementById("d1");
	  alert(d.innerText);
  }
  function fn2(){
	  //获取id为d1的元素
	//  var d1=document.getElementById("d1");
	  //修改
	 d1.innerText="xxx";
  }
  
  </script>
</body>
</html>